import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const original = VueRouter.prototype.push
VueRouter.prototype.push = function push(location){
  return original.call(this, location).catch(err=> err)
}

const routes = [
  {
    path: '/',
    name: 'home',
    component: Home
  },
  {
    path: '/login',
    name: 'login',
    component: ()=> import('../views/login')
  },
  {
    path: '/register',
    name: 'register',
    component: ()=> import('../views/register')
  },
  {
    path: '/search',
    name: 'search',
    component: ()=> import('../views/search')
  },
  {
    path: '/collect',
    name: 'collect',
    component: ()=> import('../views/collect')
  },
  {
    path: '/newsDetail',
    name: 'newsDetail',
    component: ()=> import('../views/newsDetail')
  },
  {
    path: '/my',
    name: 'my',
    component: ()=> import('../views/my')
  },
]

const router = new VueRouter({
  routes
})

export default router
